package com.zx.idc.backend.gui.config.aspect;


import com.zx.idc.backend.gui.shiro.TokenManagerUtil;
import com.zx.idc.ds.sys.service.ISysUserService;
import com.zx.idc.ds.tlog.service.ITLogActiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录拦截器
 *
 * @author rxliuli
 */
@Component
public class DevLoginInterceptor implements HandlerInterceptor {
    private final ISysUserService sysUserService;
    private final ITLogActiveService tlogActiveService;

    @Autowired
    private TokenManagerUtil tokenManagerUtil;

    @Autowired
    public DevLoginInterceptor(ISysUserService sysUserService, ITLogActiveService tlogActiveService) {
        this.sysUserService = sysUserService;
        this.tlogActiveService = tlogActiveService;
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        /*SysUser sysUser = tokenManagerUtil.getCurrentUser();
        if (sysUser == null) {
            sysUser = sysUserService.selectOne(new SysUser().setLoginName("rxliuli"));
//            final LocalDateTime now = LocalDateTime.now();
//            tlogActiveService.insert(new TlogActive(request.getSession().getId(), sysUser.getId(), now, now, NetworkUtil.getIpAddress(request)));
        }
        UserSessionUtil.set(sysUser);*/
        return true;
    }
}
